package com.koicarp.agent.workflow.first;

import dev.langchain4j.model.chat.ChatLanguageModel;
import dev.langchain4j.model.ollama.OllamaChatModel;
import dev.langchain4j.service.AiServices;

import java.time.Duration;
import java.util.ArrayList;
import java.util.List;

/**
 * @Author: liuxia
 * @CreateTime: 2025/2/20 下午8:57
 * @Description:
 */
public class FirstTest {
    static String MODEL_NAME = "qwen2:7b";
    static String BASE_URL = "http://localhost:11434"; // local ollama base url

    public static void main(String[] args) {
        ChatLanguageModel model = OllamaChatModel.builder()
                .baseUrl(BASE_URL)
                .modelName(MODEL_NAME)
                .timeout(Duration.ofHours(10))
                .build();

        Assistant assistant = AiServices.create(Assistant.class, model);
        String chat = assistant.chat("你好，我想知道4396-158等于多少");
        System.out.println(chat);
        // 预测打印：
        // [你好]
        // [4396-158等于多少?]

        List<String> chats = new ArrayList<>();
        chats.add("你好");
        chats.add("43960-158等于多少?");
        ChatTypeService chatTypeService = AiServices.create(ChatTypeService.class, model);
        for(String c: chats) {
            ChatTypeEnum typeEnum = chatTypeService.classify(c);
            System.out.println("你的分类是:" + typeEnum.getDescription());
//            switch (typeEnum) {
//                case CHAT:
//                    System.out.println("你的分类是:" + typeEnum.getDescription());
//                    break;
//                case COMPUTE:
//                    System.out.println("你的分类是:" + typeEnum.getDescription());
//                    break;
//                case ANSWER_QUESTIONS:
//                    System.out.println("你的分类是:" + typeEnum.getDescription());
//                    break;
//                case IMAGE_GENERATION:
//                    System.out.println("你的分类是:" + typeEnum.getDescription());
//                    break;
//            }
        }
    }
}
